{ "cells": [ { "cell_type": "markdown", "metadata": {}, "source": [ "# Tutor Magic in IPython\n", "\n", "This notebook demonstrates the %%tutor magic as used in IPython notebook.\n", "\n", "First, you'll need the following installed:\n", "\n", "1. IPython/Jupyter\n", "2. [Metakernel](https://github.com/Calysto/metakernel)\n", "\n", "Next, you'll need to use the magics in IPython:" ] }, { "cell_type": "code", "execution_count": 1, "metadata": { "collapsed": true }, "outputs": [], "source": [ "from metakernel import register_ipython_magics\n", "register_ipython_magics()" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "Finally, put a %%tutor at the top of any cell with Python code, and watch the visualization:" ] }, { "cell_type": "code", "execution_count": 2, "metadata": { "collapsed": false }, "outputs": [ { "data": { "text/html": [ "\n", " \n", " " ], "text/plain": [ "" ] }, "metadata": {}, "output_type": "display_data" } ], "source": [ "%%tutor\n", "\n", "mylist = []\n", "\n", "for i in range(10):\n", " mylist.append(i ** 2)" ] }, { "cell_type": "markdown", "metadata": { "collapsed": true }, "source": [ "Try it out!" ] } ], "metadata": { "kernelspec": { "display_name": "Python 3", "language": "python", "name": "python3" }, "language_info": { "codemirror_mode": { "name": "ipython", "version": 3 }, "file_extension": ".py", "mimetype": "text/x-python", "name": "python", "nbconvert_exporter": "python", "pygments_lexer": "ipython3", "version": "3.4.3" } }, "nbformat": 4, "nbformat_minor": 0 }